//计算土壤水分适宜度
export const getSoilMoisture = (H=80) => {
	H = H?H:70
	let data = null
	const H0 = 80//最适宜
	const H1 = 55//下限
	const H2 = 90//上限
	if (H > H1 && H < H0) {
		data = 1 - (H0 - H) / (H0 - H1)
	} else if (H >= H0 && H < H2) {
		data = 1 - (H - H0) / (H2 - H0)
	} else {
		data = 0
	}
	return data
};

//计算土壤温度适宜度
export const getSoilTem = (T=10) => {
	T = T?T:7
	let data = null
	const T0 = 10//最适宜
	const T1 = 6//下限
	if (T > T1 && T < T0) {
		data = 1 - Math.pow((T0 - T), 2) / Math.pow((T0 - T1), 2)
	} else if (T >= T0) {
		data = 1
	} else {
		data = 0
	}
	return data
};

//计算土壤解冻深度适宜度
export const getSoilDepth = (D) => {
	let data = null
	const D0 = 60//最适宜
	const D1 = 30//下限
	if (D > D1 && D < D0) {
		data = 1 - (D0 - D) / (D0 - D1)
	} else if (D >= D0) {
		data = 1
	} else {
		data = 0
	}
	return data
};

//计算天气条件适宜度
export const getRain = (R) => {
	let data = null
	const R2 = 5//上限
	if (R < R2) {
		data = 1 - (R / R2)
	} else {
		data = 0
	}
	return data
};

//计算播种气象适宜度
export const getSuitability = (H, T, D, R) => {
	let data = null
	const a = 0.35//权重系数
	const b = 0.30//权重系数
	const c = 0.15//权重系数
	const d = 0.20//权重系数
	if (H == 0 || T == 0 || D == 0 || R == 0) {
		data = 0
	} else {
		data = a * H + b * T + c * D + d * R
	}
	return data
};

